
TRIGGER PROCEDURE FOR WRITE OF rqd_det OLD BUFFER OLD_RQD_DET.

{mfdeclre.i }
define new shared work-table wf_old_rqd_det like rqd_det.

/* fdn 2004/10/28 Modify Record processing */
HK:
do:
    if can-find(first dt_mstr where dt_table = "rqd_det" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(rqd_det), input "rqd_det").

    if not can-find ( first dt_mstr where dt_table = "rqd_det" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_rqd_det ) then do:
        create wf_old_rqd_det.
        if recid(wf_old_rqd_det)= -1 then .
    end.
    
    buffer-copy old_rqd_det to wf_old_rqd_det no-error.

    for each dt_mstr no-lock where dt_table = "rqd_det" and dt_type = "MOD" :
    
        case dt_field :

            when "rqd_nbr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_nbr, input rqd_det.rqd_nbr,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_line" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_line), input string(rqd_det.rqd_line),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_part" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_part, input rqd_det.rqd_part,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_req_qty" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_req_qty), input string(rqd_det.rqd_req_qty),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_um_conv" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_um_conv), input string(rqd_det.rqd_um_conv),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_vend" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_vend, input rqd_det.rqd_vend,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_ship" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_ship, input rqd_det.rqd_ship,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_vpart" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_vpart, input rqd_det.rqd_vpart,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_taxable" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_taxable), input string(rqd_det.rqd_taxable),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_disc_pct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_disc_pct), input string(rqd_det.rqd_disc_pct),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_due_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_due_date), input string(rqd_det.rqd_due_date),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_desc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_desc, input rqd_det.rqd_desc,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_type" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_type, input rqd_det.rqd_type,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_max_cost" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_max_cost), input string(rqd_det.rqd_max_cost),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_category" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_category, input rqd_det.rqd_category,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_status" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_status, input rqd_det.rqd_status,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_rev" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_rev, input rqd_det.rqd_rev,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_loc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_loc, input rqd_det.rqd_loc,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_insp_rqd" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_insp_rqd), input string(rqd_det.rqd_insp_rqd),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_acct" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_acct, input rqd_det.rqd_acct,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_cc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_cc, input rqd_det.rqd_cc,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_project" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_project, input rqd_det.rqd_project,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_need_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_need_date), input string(rqd_det.rqd_need_date),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_pur_cost" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_pur_cost), input string(rqd_det.rqd_pur_cost),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_aprv_stat" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_aprv_stat, input rqd_det.rqd_aprv_stat,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_rel_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_rel_date), input string(rqd_det.rqd_rel_date),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_site" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_site, input rqd_det.rqd_site,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_um" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_um, input rqd_det.rqd_um,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_cmtindx" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_cmtindx), input string(rqd_det.rqd_cmtindx),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_oot_ponetcst" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_oot_ponetcst), input string(rqd_det.rqd_oot_ponetcst),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_oot_poum" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_oot_poum, input rqd_det.rqd_oot_poum,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_oot_rqnetcst" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_oot_rqnetcst), input string(rqd_det.rqd_oot_rqnetcst),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_oot_rqum" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_oot_rqum, input rqd_det.rqd_oot_rqum,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_pr_list" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_pr_list, input rqd_det.rqd_pr_list,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_pr_list2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_pr_list2, input rqd_det.rqd_pr_list2,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_grade" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_grade, input rqd_det.rqd_grade,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_expire" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_expire), input string(rqd_det.rqd_expire),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_rctstat" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_rctstat, input rqd_det.rqd_rctstat,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_assay" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_assay), input string(rqd_det.rqd_assay),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_lot_rcpt" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_lot_rcpt), input string(rqd_det.rqd_lot_rcpt),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__chr01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__chr01, input rqd_det.rqd__chr01,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__chr02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__chr02, input rqd_det.rqd__chr02,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__chr03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__chr03, input rqd_det.rqd__chr03,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__chr04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__chr04, input rqd_det.rqd__chr04,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__qadc01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__qadc01, input rqd_det.rqd__qadc01,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__qadc02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__qadc02, input rqd_det.rqd__qadc02,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__qadc03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__qadc03, input rqd_det.rqd__qadc03,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd__qadc04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd__qadc04, input rqd_det.rqd__qadc04,
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_open" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_rqd_det.rqd_open), input string(rqd_det.rqd_open),
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

            when "rqd_oot_extra[1]" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_rqd_det.rqd_oot_extra[1], input rqd_det.rqd_oot_extra[1],
                    input recid(rqd_det), input rqd_det.rqd_nbr, input string(rqd_det.rqd_line), input "", input "",
                    input "", input "", input "", input "").

        end.

    end.
end.

{hkdttrans.i}
